/*
 * Copyright (c) 2017. All  rights reserved.
 * 项目名：microservice-base
 * 文件名：BaseSVI.java
 * Date  ：17-10-11 下午4:47
 * Author：abin
 *
 */

package com.microservice.base.service.impl;

import java.util.List;

import com.microservice.base.mapper.BaseMP;
import com.microservice.base.service.BaseSV;
import com.microservice.base.vo.searchVo.SearchVo;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;


@Service
@Transactional
public abstract class BaseSVI<T> implements BaseSV<T> {

    protected abstract BaseMP<T> getMapper();

    @Override
    public void save(T t) {
        getMapper().save(t);
    }

    @Override
    public void saveBatch(List<T> list) {
        getMapper().saveBatch(list);
    }

    @Override
    public void delete(String id) {
        getMapper().delete(id);
    }

    @Override
    public void deleteBatch(String[] ids) {
        getMapper().deleteBatch(ids);
    }

    @Override
    public int update(T t) {
       return getMapper().update(t);
    }

    @Override
    @Transactional(readOnly = true)
    public List<T> query(SearchVo searchVo) {
        return getMapper().query(searchVo);
    }

    @Override
    @Transactional(readOnly = true)
    public T get(String id) {
        return getMapper().get(id);
    }

    @Override
    public int getCount(SearchVo searchVo) {
        return getMapper().getCount(searchVo);
    }

    @Override
    @Transactional(readOnly = true)
    public List<T> queryAll() {
        return getMapper().queryAll();
    }
}
